import React, { useState } from 'react';
import { Modal, Progress, Row, Col, Checkbox, Button } from 'antd';

function UpdateCheck(props) {
  // const [visible, setVisible] = useState(false);
  const { visible, path, setVisible,showPercent ,percent} = props;

  const [noPrompt, setNoPrompt] = useState<boolean>(false);
  return (
    <div>
      <Modal
        title="提示"
        okText="确认"
        cancelText="取消"
        visible={visible}
        onOk={()=>{
            window.electron.ipcRenderer.sendMessage('downloadUpdate')
            // setVisible(false);

        }}
        maskClosable={false}
        footer={showPercent?false:undefined}
        onCancel={() => {
            if(showPercent){
                window.electron.ipcRenderer.sendMessage('quitDownload')
                setVisible(false);
                
            }else{
                window.electron.ipcRenderer.sendMessage('quitDownload')
                setVisible(false);

            }
        }}
      >
        <div>
            {showPercent?"正在下载中。请不要关闭此页面。否则下载将中断。下载完成后将自动进行安装。":'发现了新版本的安装包，你是否想现在进行更新'}
            {showPercent&&<Row>
                <Progress percent={percent} />
            </Row>
            }

        </div>
      </Modal>
    </div>
  );
}

export default UpdateCheck;
